﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogManager.Windows
{
    public static class WindowsEventLevelHelper
    {
        private const byte ERROR = 2;
        private const byte WARNING = 3;
        private const byte INFORMATION = 4;
        private const byte CRITICAL = 1;

        /// <summary>
        /// Get level by the byte value
        /// </summary>
        /// <param name="level">The byte value containing the level information</param>
        /// <returns>The analyzed level</returns>
        public static string GetLevel(byte? level)
        {
            switch (level)
            {
                case ERROR:
                    return "Error";
                case WARNING:
                    return "Warning";
                case INFORMATION:
                    return "Information";
                case CRITICAL:
                    return "Critical";
                default:
                    return "Information";
            }
        }

        public static byte GetLevel(string level)
        {
            switch (level)
            {
                case "Error":
                    return ERROR;
                case "Warning":
                    return WARNING;
                case "Information":
                    return INFORMATION;
                case "Critical":
                    return CRITICAL;
                default:
                    return INFORMATION;
            }
        }
    }
}
